package com.yimi.yinhepda.db.table;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.pda.uce.commom.contrarywind.interfaces.IPickerViewData;
import com.yimi.yinhepda.entity.response.DeptInfoResponse;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 000432
 * @date 2017/4/14
 * 网点部门表
 */
@DatabaseTable(tableName = "departmentTable")
public class DepartmentTable implements IPickerViewData {
    @DatabaseField(generatedId = true)
    private Long id;
    /**
     * 主键
     */
    @DatabaseField(uniqueIndex = true)
    private long deptBaseInfoId;
    /**
     * 网点编码
     */
    @DatabaseField(index = true)
    private String deptCode;
    /**
     * 网点名称
     */
    @DatabaseField
    private String deptName;
    /**
     * 名称拼音
     */
    @DatabaseField
    private String deptPinyin;
    /**
     * 启用日期
     */
    @DatabaseField
    private String enableTime;
    /**
     * 网点类型：2,3,4分别是一级网点，二级网点，三级网点; 5,6分别是一级分拨，二级分拨
     */
    @DatabaseField
    private int deptType;
    /**
     * 对外名称
     */
    @DatabaseField
    private String outDeptName;
    /**
     * 所属企业
     */
    @DatabaseField
    private String belongComp;
    /**
     * 行政区域code
     */
    @DatabaseField
    private String districtCode;
    /**
     * 网点状态
     */
    @DatabaseField
    private int status;
    /**
     * 上级组织
     */
    @DatabaseField
    private String parentGroupCode;
    /**
     * 所属账套
     */
    @DatabaseField
    private String belongCompAccount;
    /**
     * 是否驻地部门
     */
    @DatabaseField
    private int isResidentDept;
    /**
     * 是否跨行政省区
     */
    @DatabaseField
    private int isCrossProvince;
    /**
     * 创建人
     */
    @DatabaseField
    private String creater;
    /**
     * 创建时间
     */
    @DatabaseField
    private String createrTime;
    /**
     * 修改人
     */
    @DatabaseField
    private String modifier;
    /**
     * 修改时间
     */
    @DatabaseField
    private String modifierTime;
    /**
     * 是否删除 0未删除；1 已删除，默认0
     */
    @DatabaseField
    private int isDelete;
    /**
     * 最后修改时间
     */
    @DatabaseField
    private String latestTime;
    /**
     * 版本号
     */
    @DatabaseField
    private int recordVersion;
    /**
     * 省编号
     */
    @DatabaseField
    private int theProvinceCode;
    /**
     * 省名称
     */
    @DatabaseField
    private String theProvinceName;
    /**
     * 城市编号
     */
    @DatabaseField
    private int theCityCode;
    /**
     * 城市名称
     */
    @DatabaseField
    private String theCityName;
    /**
     * 区编号
     */
    @DatabaseField
    private int theCountyCode;
    /**
     * 区名称
     */
    @DatabaseField
    private String theCountyName;
    /**
     * 公司代码
     */
    @DatabaseField
    private String compCode;
    /**
     * 虚拟网点类型 数据字典key:virtual_node_type
     * 6-分拨自提，7-跨越虚拟网点
     */
    @DatabaseField
    private String column26;
    /**
     * 所属分拨（编码）
     */
    @DatabaseField
    private String belongForward;
    /**
     * 0-快运,1-快递
     */
    @DatabaseField
    private int isOmg;

    private boolean isCheck;

    public DepartmentTable(long deptBaseInfoId, String deptCode, String deptName, String deptPinyin, String enableTime, int deptType,
                           String outDeptName, String belongComp, String districtCode, int status, String parentGroupCode, String belongCompAccount, int isResidentDept,
                           int isCrossProvince, String creater, String createrTime, String modifier, String modifierTime, int isDelete, String latestTime,
                           int recordVersion, int theProvinceCode, String theProvinceName, int theCityCode, String theCityName, int theCountyCode, String theCountyName,
                           String compCode, String column26, String belongForward, int isOmg) {
        this.deptBaseInfoId = deptBaseInfoId;
        this.deptCode = deptCode;
        this.deptName = deptName;
        this.deptPinyin = deptPinyin;
        this.enableTime = enableTime;
        this.deptType = deptType;
        this.outDeptName = outDeptName;
        this.belongComp = belongComp;
        this.districtCode = districtCode;
        this.status = status;
        this.parentGroupCode = parentGroupCode;
        this.belongCompAccount = belongCompAccount;
        this.isResidentDept = isResidentDept;
        this.isCrossProvince = isCrossProvince;
        this.creater = creater;
        this.createrTime = createrTime;
        this.modifier = modifier;
        this.modifierTime = modifierTime;
        this.isDelete = isDelete;
        this.latestTime = latestTime;
        this.recordVersion = recordVersion;
        this.theProvinceCode = theProvinceCode;
        this.theProvinceName = theProvinceName;
        this.theCityCode = theCityCode;
        this.theCityName = theCityName;
        this.theCountyCode = theCountyCode;
        this.theCountyName = theCountyName;
        this.compCode = compCode;
        this.column26 = column26;
        this.belongForward = belongForward;
        this.isOmg = isOmg;
    }

    public DepartmentTable() {
    }

    /**
     * 访问接口返回的数据转换
     */
    public static List<DepartmentTable> parse(List<DeptInfoResponse.DataBean> dataBeens) {
        List<DepartmentTable> list = new ArrayList<DepartmentTable>();
        if (dataBeens != null && dataBeens.size() > 0) {
            for (DeptInfoResponse.DataBean item : dataBeens) {
                DepartmentTable mDepartmentTable;
                if (item.getDistrictTheRegionVo() == null) {
                    mDepartmentTable =
                            new DepartmentTable(item.getDeptBaseInfoId(), item.getDeptCode(), item.getDeptName(), item.getDeptPinyin(), item.getEnableTime(),
                                    item.getDeptType(), item.getOutDeptName(), item.getBelongComp(), item.getDistrictCode(), item.getStatus(),
                                    item.getParentGroupCode(), item.getBelongCompAccount(), item.getIsResidentDept(), item.getIsCrossProvince(), item.getCreater(),
                                    item.getCreaterTime(), item.getModifier(), item.getModifierTime(), item.getIsDelete(), item.getLatestTime(),
                                    item.getRecordVersion(), -1, "", -1, "", -1, "",
                                    item.getCompCode(), item.getColumn26(), item.getBelongForward(), item.getIsOmg());
                } else {
                    mDepartmentTable =
                            new DepartmentTable(item.getDeptBaseInfoId(), item.getDeptCode(), item.getDeptName(), item.getDeptPinyin(), item.getEnableTime(),
                                    item.getDeptType(), item.getOutDeptName(), item.getBelongComp(), item.getDistrictCode(), item.getStatus(),
                                    item.getParentGroupCode(), item.getBelongCompAccount(), item.getIsResidentDept(), item.getIsCrossProvince(), item.getCreater(),
                                    item.getCreaterTime(), item.getModifier(), item.getModifierTime(), item.getIsDelete(), item.getLatestTime(),
                                    item.getRecordVersion(), item.getDistrictTheRegionVo().getTheProvinceCode(), item.getDistrictTheRegionVo().getTheProvinceName(),
                                    item.getDistrictTheRegionVo().getTheCityCode(), item.getDistrictTheRegionVo().getTheCityName(),
                                    item.getDistrictTheRegionVo().getTheCountyCode(), item.getDistrictTheRegionVo().getTheCountyName(), item.getCompCode(),
                                    item.getColumn26(), item.getBelongForward(), item.getIsOmg());
                }

                list.add(mDepartmentTable);
            }
        }

        return list;
    }

    public int getIsOmg() {
        return isOmg;
    }

    public void setIsOmg(int isOmg) {
        this.isOmg = isOmg;
    }

    public String getBelongForward() {
        return belongForward;
    }

    public void setBelongForward(String belongForward) {
        this.belongForward = belongForward;
    }

    public String getColumn26() {
        return column26;
    }

    public void setColumn26(String column26) {
        this.column26 = column26;
    }

    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean check) {
        isCheck = check;
    }

    public String getTheCountyName() {
        return theCountyName;
    }

    public void setTheCountyName(String theCountyName) {
        this.theCountyName = theCountyName;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public long getDeptBaseInfoId() {
        return deptBaseInfoId;
    }

    public void setDeptBaseInfoId(long deptBaseInfoId) {
        this.deptBaseInfoId = deptBaseInfoId;
    }

    public String getDeptCode() {
        return deptCode;
    }

    public void setDeptCode(String deptCode) {
        this.deptCode = deptCode;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getDeptPinyin() {
        return deptPinyin;
    }

    public void setDeptPinyin(String deptPinyin) {
        this.deptPinyin = deptPinyin;
    }

    public String getEnableTime() {
        return enableTime;
    }

    public void setEnableTime(String enableTime) {
        this.enableTime = enableTime;
    }

    public int getDeptType() {
        return deptType;
    }

    public void setDeptType(int deptType) {
        this.deptType = deptType;
    }

    public String getOutDeptName() {
        return outDeptName;
    }

    public void setOutDeptName(String outDeptName) {
        this.outDeptName = outDeptName;
    }

    public String getBelongComp() {
        return belongComp;
    }

    public void setBelongComp(String belongComp) {
        this.belongComp = belongComp;
    }

    public String getCompCode() {
        return compCode;
    }

    public void setCompCode(String compCode) {
        this.compCode = compCode;
    }

    public String getDistrictCode() {
        return districtCode;
    }

    public void setDistrictCode(String districtCode) {
        this.districtCode = districtCode;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getParentGroupCode() {
        return parentGroupCode;
    }

    public void setParentGroupCode(String parentGroupCode) {
        this.parentGroupCode = parentGroupCode;
    }

    public String getBelongCompAccount() {
        return belongCompAccount;
    }

    public void setBelongCompAccount(String belongCompAccount) {
        this.belongCompAccount = belongCompAccount;
    }

    public int getIsResidentDept() {
        return isResidentDept;
    }

    public void setIsResidentDept(int isResidentDept) {
        this.isResidentDept = isResidentDept;
    }

    public int getIsCrossProvince() {
        return isCrossProvince;
    }

    public void setIsCrossProvince(int isCrossProvince) {
        this.isCrossProvince = isCrossProvince;
    }

    public String getCreater() {
        return creater;
    }

    public void setCreater(String creater) {
        this.creater = creater;
    }

    public String getCreaterTime() {
        return createrTime;
    }

    public void setCreaterTime(String createrTime) {
        this.createrTime = createrTime;
    }

    public String getModifier() {
        return modifier;
    }

    public void setModifier(String modifier) {
        this.modifier = modifier;
    }

    public String getModifierTime() {
        return modifierTime;
    }

    public void setModifierTime(String modifierTime) {
        this.modifierTime = modifierTime;
    }

    public int getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(int isDelete) {
        this.isDelete = isDelete;
    }

    public String getLatestTime() {
        return latestTime;
    }

    public void setLatestTime(String latestTime) {
        this.latestTime = latestTime;
    }

    public int getRecordVersion() {
        return recordVersion;
    }

    public void setRecordVersion(int recordVersion) {
        this.recordVersion = recordVersion;
    }

    public int getTheProvinceCode() {
        return theProvinceCode;
    }

    public void setTheProvinceCode(int theProvinceCode) {
        this.theProvinceCode = theProvinceCode;
    }

    public String getTheProvinceName() {
        return theProvinceName;
    }

    public void setTheProvinceName(String theProvinceName) {
        this.theProvinceName = theProvinceName;
    }

    public int getTheCityCode() {
        return theCityCode;
    }

    public void setTheCityCode(int theCityCode) {
        this.theCityCode = theCityCode;
    }

    public String getTheCityName() {
        return theCityName;
    }

    public void setTheCityName(String theCityName) {
        this.theCityName = theCityName;
    }

    public int getTheCountyCode() {
        return theCountyCode;
    }

    public void setTheCountyCode(int theCountyCode) {
        this.theCountyCode = theCountyCode;
    }

    @Override
    public String getPickerViewText() {
        return deptName;
    }
}
